/**
 * @Description: checkout指令
 * @author Beon
 * @date 2021/1/28
*/
import * as childProcess from 'child_process';
import {ErrorCatch} from '../decorators/errorCatch';
import '../utils/consoleColor';

export class Checkout{

	/**
	 * 进行新建分支操作
	 * @param {String} branch 新建分支名称
	 * @param {String} repoPath 执行路径
	 * @returns {Promise<void>}
	 */
	@ErrorCatch.errorExit('自动新建分支失败，请检查报错信息')
    static async checkNewBranch (branch: string, repoPath?: string): Promise<void> {
        await childProcess.execSync(`git checkout -b ${branch}`, { cwd: repoPath });
    }
}
